@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
:root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
}

  .dark {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;
  }
}

@layer components {
  .empty-chat {
    @apply flex flex-col items-center justify-center h-full text-center p-8;
  }

  .empty-chat-icon {
    @apply mb-4 p-4 rounded-full bg-slate-100 dark:bg-slate-800 text-slate-500 dark:text-slate-400;
  }

  .messages-wrapper {
    @apply min-h-full;
  }

  .custom-scrollbar {
    @apply overflow-auto;
  }
}

/* 自定义滚动条样式 */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 3px;
  transition: background-color 0.2s;
}

.custom-scrollbar:hover::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
}

.dark .custom-scrollbar:hover::-webkit-scrollbar-thumb {
  background-color: #334155;
}

/* Markdown 样式 */
.prose pre {
  background-color: #1e1e1e;
  border-radius: 0.375rem;
  padding: 1rem;
  overflow-x: auto;
  position: relative;
}

.prose pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  color: #e6e6e6;
}

.prose code {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

.dark .prose code {
  background-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.prose p {
  margin-bottom: 1em;
}

.dark .prose p {
  color: #e2e8f0;
}

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
}

.dark .prose h1, .dark .prose h2, .dark .prose h3, 
.dark .prose h4, .dark .prose h5, .dark .prose h6 {
  color: #f1f5f9;
}

.prose h1 {
  font-size: 1.75em;
}

.prose h2 {
  font-size: 1.5em;
}

.prose h3 {
  font-size: 1.25em;
}

.prose ul, .prose ol {
  padding-left: 1.5em;
  margin-bottom: 1em;
}

.dark .prose ul, .dark .prose ol {
  color: #e2e8f0;
}

.prose li {
  margin-bottom: 0.25em;
}

.prose blockquote {
  border-left: 4px solid #e2e8f0;
  padding-left: 1em;
  margin-left: 0;
  margin-right: 0;
  font-style: italic;
  color: #4a5568;
}

.dark .prose blockquote {
  border-left-color: #4a5568;
  color: #cbd5e1;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
  overflow-x: auto;
  display: block;
}

.prose th, .prose td {
  border: 1px solid #e2e8f0;
  padding: 0.5em;
}

.dark .prose th, .dark .prose td {
  border-color: #4a5568;
}

.prose th {
  background-color: #f7fafc;
  font-weight: 600;
}

.dark .prose th {
  background-color: #2d3748;
}

/* 代码块增强样式 */
.prose .code-block {
  position: relative;
  margin: 1.5em 0;
}

.prose .code-block pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.875em;
  line-height: 1.7;
  border-radius: 0.5rem;
  background-color: #1e1e1e;
  color: #e6e6e6;
  padding: 1.25rem;
  margin: 0;
  overflow-x: auto;
}

.prose .code-block pre::-webkit-scrollbar {
  height: 8px;
}

.prose .code-block pre::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.prose .code-block pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.prose .code-block pre::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.code-copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  background-color: rgba(0, 0, 0, 0.3);
  color: #d4d4d4;
  border-radius: 0.25rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.code-block:hover .code-copy-button {
  opacity: 1;
}

/* 增强消息卡片样式 */
.message-card {
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.dark .message-card {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.message-card.user {
  background-color: rgba(59, 130, 246, 0.05);
}

.dark .message-card.user {
  background-color: rgba(59, 130, 246, 0.1);
}

.message-card.assistant {
  background-color: rgba(255, 255, 255, 0.5);
}

.dark .message-card.assistant {
  background-color: rgba(55, 65, 81, 0.3);
}

/* 语言标签 */
.code-language-label {
  position: absolute;
  top: 0;
  left: 1rem;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background-color: rgba(0, 0, 0, 0.6);
  color: #d4d4d4;
  padding: 0.25rem 0.5rem;
  border-radius: 0 0 0.25rem 0.25rem;
  text-transform: lowercase;
  letter-spacing: 0.025em;
  z-index: 1;
}

/* 添加Markdown内容样式 */
.markdown-content {
  line-height: 1.6;
  overflow-wrap: break-word;
}

/* 标题样式 */
.markdown-content h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 1.4rem;
  margin-bottom: 0.8rem;
}

.markdown-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.2rem;
  margin-bottom: 0.6rem;
}

.markdown-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

/* 段落样式 */
.markdown-content p {
  margin-bottom: 1rem;
}

/* 列表样式 */
.markdown-content ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-content ol {
  list-style-type: decimal;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-content li {
  margin-bottom: 0.25rem;
}

/* 代码块样式 */
.markdown-content pre {
  background-color: #282c34;
  border-radius: 0.375rem;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}

.markdown-content code {
  font-family: monospace;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  background-color: rgba(0, 0, 0, 0.1);
}

.dark .markdown-content code {
  background-color: rgba(255, 255, 255, 0.1);
}

.markdown-content pre code {
  padding: 0;
  background-color: transparent;
  color: #f8f8f2;
}

/* 表格样式 */
.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid #e2e8f0;
  padding: 0.5rem;
}

.dark .markdown-content th,
.dark .markdown-content td {
  border-color: #334155;
}

.markdown-content th {
  background-color: #f1f5f9;
  font-weight: 600;
}

.dark .markdown-content th {
  background-color: #0f172a;
}

/* 引用样式 */
.markdown-content blockquote {
  border-left: 4px solid #e2e8f0;
  padding-left: 1rem;
  margin-left: 0;
  margin-right: 0;
  font-style: italic;
  color: #64748b;
}

.dark .markdown-content blockquote {
  border-left-color: #334155;
  color: #94a3b8;
}

/* 水平线样式 */
.markdown-content hr {
  border: 0;
  height: 1px;
  background-color: #e2e8f0;
  margin: 1.5rem 0;
}

.dark .markdown-content hr {
  background-color: #334155;
}

/* 链接样式 */
.markdown-content a {
  color: #3b82f6;
  text-decoration: underline;
}

.dark .markdown-content a {
  color: #60a5fa;
}

.markdown-content a:hover {
  text-decoration: none;
}

/* 消息容器样式 */
.message-container {
  width: 100%;
  animation: fade-in 0.3s ease-in-out;
}

.message-card {
  position: relative;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
}

.message-card:hover {
  transform: translateY(-1px);
}

/* 添加消息动画 */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 修复高度问题 */
.h-\[calc\(100vh-10rem\)\] {
  height: calc(100vh - 10rem);
  min-height: 300px;
}

/* 输入框样式增强 */
textarea::-webkit-scrollbar {
  width: 6px;
}

textarea::-webkit-scrollbar-track {
  background: transparent;
}

textarea::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.dark textarea::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.2);
}

/* 输入框聚焦动画 */
@keyframes input-focus-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.dark .input-focus-animation {
  animation: input-focus-pulse-dark 2s infinite;
}

@keyframes input-focus-pulse-dark {
  0% {
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(96, 165, 250, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0);
  }
}

/* 修复高度计算，适应更大的输入框 */
.h-\[calc\(100vh-11rem\)\] {
  height: calc(100vh - 11rem);
  min-height: 300px;
}

/* 弹窗动画效果 */
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-fade-in {
  animation: fade-in 0.2s ease-out;
}

.animate-scale-in {
  animation: scale-in 0.2s ease-out;
}

/* 增强滑块样式 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  outline: none;
}

.dark input[type="range"] {
  background: #334155;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
}

.dark input[type="range"]::-webkit-slider-thumb {
  background: #60a5fa;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.dark input[type="range"]::-moz-range-thumb {
  background: #60a5fa;
}
